<template>
  <div class="number-key">
    <div v-for="(item,index) in numbers" :key="item"
         class="btn"
         :class="{'zero':index==0}">
      {{ item }}
    </div>
    <!--<div class="btn zero">0</div>
    <div class="btn">1</div>
    <div class="btn">2</div>
    <div class="btn">3</div>
    <div class="btn">4</div>
    <div class="btn">5</div>
    <div class="btn">6</div>
    <div class="btn">7</div>
    <div class="btn">8</div>
    <div class="btn">9</div>-->
    <div class="btn">.</div>
    <div class="btn del"><span class="ok-icon icon-shanchu"></span></div>
    <div @click="onSusscess" class="btn ok">确定</div>
  </div>
</template>

<script type="es6">
export default {
  name: "NumberKey",
  components: {},
  props: {

  },
  data() {
    let numbers = this.onNumber(true);
    return {
      numbers
    };
  },
  mounted() {
  },
  methods: {
    onNumber(isDisrupt) {
      let numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
      if (isDisrupt) {
        numbers.sort(function () {
          return Math.random() > 0.5 ? -1 : 1;
        });
      }
      return numbers;
    },
    onSusscess() {
      this.numbers = this.onNumber(true);
    }
  }
}
</script>

<style lang="scss" scoped>
@import "./css/ok-color";

.number-key {
  box-sizing: border-box;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  text-align: center;
  grid-auto-rows: minmax(64px, auto);
  font-size: 0;
  position: relative;
  max-width: 100%;
  padding: 10px;
  background: #F7F7F7;

  .btn {
    box-sizing: border-box;
    color: #333;
    background: #FFFFFF;
    font-size: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    border-radius: 5px;
    font-weight: bold;
    margin: 5px;

    &:active {
      background: #e7e7e7;
    }
  }

  .zero {
    grid-column: 1 / span 2;
    grid-row-start: 4;
  }

  .del {
    grid-row: 1 / span 1;
    grid-column: 4 / span 1;

    .ok-icon {
      color: $--black;
      font-size: 18px;
    }
  }

  .ok {
    color: #FFFFFF;
    font-size: 18px;
    grid-row: 2 / span 3;
    grid-column-start: 4;
    background: $--main;
    &:active {
      opacity: .8;
      background: $--main!important;
    }
  }
}

</style>